﻿<cfsilent>
	<cfscript>

		sessionAdvice = getProperty("serviceFactory").getBean("sessionAdvice");
		
		depId = sessionAdvice.getUserProp("teacherDepartment");
		classId = event.getArg('Class');
		
		sql = "SELECT  a.cls_id,b.sbj_id,
					   a.grade,a.cls_name,
					   b.sbj_name 
				FROM t_class a 
					 INNER JOIN t_subject b ON b.sbj_id = a.sbj_id 
				WHERE a.cls_id = :classId ";
				
		queryObj = new Query( datasource=application.dnsSlave ) ;
   		queryObj.addParam( name="classId", value=classId, cfsqltype="cf_sql_char" );
		
		rs_class= queryObj.execute( sql=sql ).getResult();
						
		sql = "SELECT 
					a.stu_id, a.stu_name, 
					a.stu_sex, t_nation.nation_name, 
					a.stu_idcard, a.stu_birthday, 
					b.student_prop, c.pa_shortname 
				FROM   t_student a 
					   INNER JOIN t_nation ON t_nation.nation_code = a.nation_code  
					   INNER JOIN t_student_status b ON b.stu_id = a.stu_id 
					   INNER JOIN t_political_affiliation c ON c.pa_code = a.pa_code 
					   INNER JOIN t_class ON t_class.cls_id = a.cls_id 
					   INNER JOIN t_subject ON t_subject.sbj_id = t_class.sbj_id 
				WHERE 
					t_class.cls_id = :class 
					AND 
					t_subject.institute_id = :depID 
				ORDER BY a.stu_id ";
				
		queryObj = new Query( datasource=application.dnsSlave ) ;
   		queryObj.addParam( name="class", value=rs_class.cls_id, cfsqltype="cf_sql_char" );
		queryObj.addParam( name="depID", value=depId, cfsqltype="cf_sql_varchar" );
		
		rs_student= queryObj.execute( sql=sql ).getResult();
									
		sql = "SELECT 
					   a.cls_id, a.cls_name, 
					   a.cls_size, a.cls_scale, 
					   b.campus_name
				FROM t_class a  
					 INNER JOIN t_campus b ON b.campus_id = a.campus_id 
				WHERE 
					  a.sbj_id = :subject 
					  AND 
					  a.grade = :grade 
				ORDER BY a.cls_name";	
												
		queryObj = new Query( datasource=application.dnsSlave ) ;
   		queryObj.addParam( name="subject", value=rs_class.sbj_id, cfsqltype="cf_sql_varchar" );
		queryObj.addParam( name="grade", value=rs_class.grade , cfsqltype="cf_sql_char" );
		
		rs_classIs= queryObj.execute( sql=sql ).getResult();
		
		dictAdvice = getProperty("serviceFactory").getBean("senateDictionaryAdvice");
		datetimeAdvice = getProperty("serviceFactory").getBean("datetimeAdvice");
		propertyAdvice = getProperty("serviceFactory").getBean("studentPropertyAdvice");
		
		event.setArg("pageTitle", "教学运行基础数据 - 学生学籍 - 班级学生列表 - " & rs_class.cls_name);
		
		currentTab = event.getArg("TabID", "labStudent");
		
		targetArgs = structNew();
		structInsert(targetArgs, "SubID", rs_class.sbj_id, true);
		structInsert(targetArgs, "TabID", "labGrade" & rs_class.grade, true);
		
		passArgs = structNew();
		structInsert(passArgs, "CLS", rs_class.cls_id);
		
		/* 计算在校学生人数 */
		inSchool = 0;
		
		for ( a=1; a LTE rs_student.recordCount; a++ ) {
			propertyAdvice.parseProperty(rs_student["student_prop"][a]);
			if ( propertyAdvice.getInSchool() ) inSchool++;
		}
		
	</cfscript>
</cfsilent>

<div id="headArea">
	<div class="uiHeader uiHeaderWithImage ptm">
		<div class="clearfix uiHeaderTop">
			<div class="uiHeaderActions rfloat">
				<a class="uiButton" href="<cfoutput>#buildURL('studentBySubject', targetArgs)#</cfoutput>"><i class="mrs img btnList"></i><span class="uiButtonText">专业班级设置</span></a>
			</div>
			<div>
				<h2 class="uiHeaderTitle">
					<i class="uiHeaderImage img icon16x16 application"></i><cfoutput>#rs_class.cls_name#</cfoutput>班学生列表
				</h2>
			</div>
		</div>
	</div>
</div>

<div class="UIElement">
	<ul class="senateFirstPage">
		<li>
			<div class="clearfix" id="summary">
				<div class="UItab">
					<div class="tabLables">
						<span <cfif currentTab eq "labStudent">class="active"</cfif> id="labStudent" tabTarget="Student">学籍档案</span>
						<span <cfif currentTab eq "labDetail">class="active"</cfif> id="labDetail" tabTarget="Detail">详细信息</span>
						<span <cfif currentTab eq "labClass">class="active"</cfif> id="labClass" tabTarget="Class">其他班级</span>
					</div>
				</div>
				<script language="javascript" type="text/javascript">
					//<![CDATA[
					<!--
					$(document).ready(function() {
						
						/* init Tab */
						$("div.tabContent").hide();
						$("div#" + $("div.tabLables span.active").attr("tabTarget")).show();
						
						$("div.tabLables > span").click(function(){
							var $targetID = $(this).attr("tabTarget");
							
							$("div.tabLables span").removeClass("active");
							$(this).addClass("active");
							
							$("div.tabContent").not('[id="' + $targetID + '"]').hide();
							$("div.tabContent#" + $targetID).show();
						});
						
					});
					// -->
					//]]>
				</script>
				
				<div id="Student" class="tabContent">

					<div class="noticeBlock">
						<div class="operation">
							<a class="uiButton uiButtonSpecial" href="<cfoutput>#buildURL('studentByClassDownloadExcel', passArgs)#</cfoutput>"><i class="mrs img btnDownload"></i><span class="uiButtonText">下载行政班学生名单</span></a>
						</div>
						<h3><cfoutput>#rs_class.cls_name#</cfoutput></h3>
						<p><span class="img icon16x16 message"></span>该行政班在籍学生 <em><cfoutput>#rs_student.recordCount#</cfoutput></em> 名, 目前在校学生 <em><cfoutput>#inSchool#</cfoutput></em> 名. </p>
						<hr/>
					</div>
					
					<div class="clearfix">
					
                        <cfloop query="rs_student" >
							
							<cfset structInsert(passArgs, "STU", rs_student.stu_id, true) />
							<cfset propertyAdvice.parseProperty(rs_student.student_prop) />
							
							<div class="UISmallUserCard">
								<div class="cardContent <cfif not propertyAdvice.getInSchool()>disabled</cfif>">
									<a href="<cfoutput>#buildURL('studentProfileView', passArgs)#</cfoutput>"><img class="img" src="<cfoutput>#getProperty('cdnServer')#</cfoutput><cfoutput>#getContextRoot()#</cfoutput>/acadmicRes/assets/graphic/userSmall.png" style="background-image: url('<cfoutput>#getContextRoot()#</cfoutput>/acadmicManager/student/portrait/<cfoutput>#rs_student.stu_id#</cfoutput>.jpg');"></a>
									<div class="cardDetail">
										<h3><a href="<cfoutput>#buildURL('studentProfileView', passArgs)#</cfoutput>"><cfoutput>#rs_student.stu_name#</cfoutput></a> (<cfoutput>#rs_student.nation_name#</cfoutput>)</h3>
										<p><cfoutput>#rs_student.stu_id#</cfoutput></p>
									</div>
								</div>
							</div>
							
						</cfloop>

					</div>
					
				</div>
				
				<div id="Detail" class="tabContent">
				
						<cfset row = 0 />
						<table class="UIEditable">
							<thead>
								<tr>
									<td width="18"></td>
									<td width="90">学号</td>
									<td>姓名</td>
									<td width="25">性别</td>
									<td width="70">出生日期</td>
									<td width="100">身份证号</td>
									<td>民族</td>
									<td>政治面貌</td>
									<td width="25">在校</td>
									<td width="18"></td>
								</tr>
							</thead>
							<tbody>
                                <cfloop query="rs_student" >
									
									<cfset row++ />
									<cfset structInsert(passArgs, "STU", rs_student.stu_id, true) />
									<cfset propertyAdvice.parseProperty(rs_student.student_prop) />
									
									<tr class="editRows <cfif not propertyAdvice.getInSchool()>alertRow</cfif>">
										<td class="index"><cfoutput>#row#</cfoutput></td>
										<td><span class="numeric"><cfoutput>#rs_student.stu_id#</cfoutput></span></td>
										<td><cfoutput>#rs_student.stu_name#</cfoutput></td>
										<td><cfif rs_student.stu_sex eq "1">男<cfelse>女</cfif></td>
										<td><span class="numeric"><cfoutput>#datetimeAdvice.formatDateString(rs_student.stu_birthday)#</cfoutput></span></td>
										<td><span class="numeric"><cfoutput>#rs_student.stu_idcard#</cfoutput></span></td>
										<td><cfoutput>#rs_student.nation_name#</cfoutput></td>
										<td><cfoutput>#rs_student.pa_shortname#</cfoutput></td>
										<td><cfif propertyAdvice.getInSchool()>是<cfelse><span class="alertCell">否</span></cfif></td>
										<td><a href="<cfoutput>#buildURL('studentProfileView', passArgs)#</cfoutput>" class="stat details"></a></td>
									</tr>
								</cfloop>
								
								<cfset structDelete( passArgs, "STU", false) />
								
							</tbody>
						</table>
					
					
				</div>
				
				
				<div id="Class" class="tabContent">
					
					<div class="noticeBlock">
						<h3><cfoutput>#rs_class.sbj_name#</cfoutput> <cfoutput>#rs_class.grade#</cfoutput>级</h3>
						<p><span class="img icon16x16 message"></span>共计<em><cfoutput>#rs_classIs.recordCount#</cfoutput></em>个行政班.</p>
						<hr/>
					</div>
					
					<cfset row = 0 />
					<table class="UIEditable">
						<thead>
							<tr>
								<td width="18"></td>
								<td>班级</td>
								<td width="80">所在校区</td>
								<td width="60" align="center">计划人数</td>
								<td width="40" align="center">学生数</td>
								<td width="18"></td>
							</tr>
						</thead>
						<tbody>
                            <cfloop query="rs_classIs" >
								<cfset structInsert(passArgs, "Class", rs_classIs.cls_id, true) />
								<cfset row++ />
								<tr class="editRows <cfif classId eq rs_classIs.cls_id>cancelRow</cfif>">
									<td class="index"><cfoutput>#row#</cfoutput></td>
									<td><cfoutput>#rs_classIs.cls_name#</cfoutput></td>
									<td><cfoutput>#rs_classIs.campus_name#</cfoutput></td>
									<td align="center"><span class="numeric"><cfoutput>#rs_classIs.cls_size#</cfoutput></span></td>
									<td align="center"><span class="numeric"><cfoutput>#rs_classIs.cls_scale#</cfoutput></span></td>
									<td><a class="stat info" href="<cfoutput>#buildURL('studentByClass', passArgs)#</cfoutput>"></a></td>
								</tr>
							</cfloop>
						</tbody>
					</table>
					
				</div>
				
			</div>
		</li>
	</ul>
</div>